<!DOCTYPE html>
<html lang="en">
  	<head>
	    <meta charset="utf-8">
	    <title>学生管理系统</title>
	    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	    <meta name="description" content="">
	    <meta name="author" content="">

	    <!-- Bootstrap core CSS -->
	    <link href="/admin/bootstrap/css/bootstrap.min.css" rel="stylesheet">
		
		<!-- Font Awesome -->
		<link href="/admin/css/font-awesome.min.css" rel="stylesheet">

		<!-- ionicons -->
		<link href="/admin/css/ionicons.min.css" rel="stylesheet">
		
		<!-- Simplify -->
		<link href="/admin/css/simplify.min.css" rel="stylesheet">
	
  	</head>

  	<body class="overflow-hidden light-background">
		<div class="wrapper no-navigation preload">
			<div class="sign-in-wrapper">
				<div class="sign-in-inner">
					<div class="login-brand text-center">
						<i class="ion-person-stalker m-right-xs" style="vertical-align: middle;"></i> 学生 <strong class="text-skin">管理系统</strong>
					</div>

					<form action="" method="post" id='regForm'>
						<div class="form-group m-bottom-md">
							<input type="email" class="form-control" name="email" placeholder="请输入邮箱">
						</div>
						<div class="form-group">
							<input type="password" name="pwd" class="form-control" placeholder="请输入密码">
						</div>
						<div class="form-group">
							<input type="password" name="pwd2" class="form-control" placeholder="请再次输入密码">
						</div>
						<div class="form-group">
							<div class="row">
								<div class="col-lg-8"><input type="text" name="code" class="form-control" placeholder="请输入验证码"></div>
								<div class="col-lg-4"><button type="button" id="sendCode"class="btn btn-success">获取验证码</button></div>
							</div>
						</div>
						<div class="form-group">
							<div class="custom-checkbox">
								<input type="checkbox" id="chkAccept" name="agree">
								<label for="chkAccept"></label>
							</div>
							同意协议 
							<a href="#" class="font-12">《学生管理系统协议》</a>
						</div>

						<div class="m-top-md p-top-sm">
							<a href="#" class="btn btn-success block" data-id="reg" id="reg">立即注册</a>
						</div>

						<div class="m-top-md p-top-sm">
							<div class="font-12 text-center m-bottom-xs">已有账号?</div>
							<a href="/admin/main/login" class="btn btn-default block">登 录</a>
						</div>
					</form>
					<div class="modal fade" id="myModal" aria-hidden="true" style="display: none;">
					  	<div class="modal-dialog modal-sm">
					  		<div class="modal-content">
					      		<div class="modal-header">
					        		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					        		<h4 class="modal-title">学生管理系统</h4>
					      		</div>
					      		<div class="modal-body" style="color:red;">
					      		</div>
					      		<div class="modal-footer">
					        		<a href="#" class="btn btn-danger block m-top-md" data-dismiss="modal">关闭</a>
					      		</div>
					    	</div>
					  	</div>
					</div>
				</div><!-- ./sign-in-inner -->
			</div><!-- ./sign-in-wrapper -->
		</div><!-- /wrapper -->

		<a href="" id="scroll-to-top" class="hidden-print"><i class="icon-chevron-up"></i></a>

	    <!-- Le javascript
	    ================================================== -->
	    <!-- Placed at the end of the document so the pages load faster -->
		
		<!-- Jquery -->
		<script src="/admin/js/jquery-1.11.1.min.js"></script>
		
		<!-- Bootstrap -->
	    <script src="/admin/bootstrap/js/bootstrap.min.js"></script>
		
		<!-- Slimscroll -->
		<script src='/admin/js/jquery.slimscroll.min.js'></script>
		
		<!-- Popup Overlay -->
		<script src='/admin/js/jquery.popupoverlay.min.js'></script>

		<!-- Modernizr -->
		<script src='/admin/js/modernizr.min.js'></script>
		
		<!-- Simplify -->
		<script src="/admin/js/simplify/simplify.js"></script>

		<!-- 正则-->
		<script src="/admin/js/common.js"></script>
		
		<script>
			// 发送验证码，到用户邮箱
			$('#sendCode').on('click',function(){
				// 获取输入的邮箱
				var email = $('input[name="email"]').val();
				// 判断邮箱是否填写
				if(!checkEmail(email)){
					$('.modal-body').html('请正确输入邮箱');
					$('#myModal').modal('show');
					return false;
				}
				// ajax结构
				$.ajax({
					url: '/admin/main/sendCode',
					type:'post',
					data:{email:email},
					dataType:'json',	// 回调的数据类型
					success:function(res){
						$('.modal-body').html(res.msg);
						$('#myModal').modal('show');
					}
				});
			});

			//ajax提交注册信息
			$('#reg').on('click', function(){
				var formData = new FormData($('#regForm')[0]);  // 括号是js表单对象
				if(!checkEmail(formData.get('email'))){
					// alert('请正确输入邮箱');
					$('.modal-body').html('请正确输入邮箱');
					$('#myModal').modal('show');
					return false;
				}
				if(checkRequired(formData.get('pwd'))){
					// alert('请输入密码');
					$('.modal-body').html('请输入密码');
					$('#myModal').modal('show');
					return false;
				}
				if(formData.get('pwd')!=formData.get('pwd2')){
					// alert('密码不一致');
					$('.modal-body').html('密码不一致');
					$('#myModal').modal('show');
					return false;
				}
				if(formData.get('agree')==undefined){
					// alert('请勾选同意协议');
					$('.modal-body').html('请勾选同意协议');
					$('#myModal').modal('show');
					return false;
				}
				$.ajax({
					url: '/admin/main/registerData',
					type: 'post',
					data: formData,
					dataType: 'json',
					processData: false,   // jQuery不要去处理发送的数据
  					contentType: false,   // jQuery不要去设置Content-Type请求头
					success: function(res){
						$('.modal-body').html(res.msg);
						$('#myModal').modal('show');
						if(res.error == 0){
							location.href="/admin/main/login"
						}
						
					}
				});
			});
		</script>
  	</body>
</html>
